<template>
    <div class="layerRtb layerRtb-threecolumn">
        <three-title :title="{name:'处理'}"></three-title>
        <div class="layerRtb-scroll thinScroll" v-scrollHeight="270">
            <div class="analyItem">
                <p class="analyItemTit tx-center">预留</p>
                <div class="analyItemCon"></div>
            </div>
            <div class="analyItem">
                <p class="analyItemTit tx-center">预留</p>
                <div class="analyItemCon"></div>
            </div>
            <div class="analyItem">
                <p class="analyItemTit tx-center">预留</p>
                <div class="analyItemCon"></div>
            </div>
        </div>
        <div class="layerRtb-footer" style="height:270px;">
            <div class="analyItem">
                <p class="analyItemTit tx-center">综合</p>
                <div class="analyItemCon">

                </div>
            </div>
            <div class="clearfix">
                <div class="fl handle-left pb10" style="min-height: 172px; width:62%">
                    <div class="clearfix">
                        <h2 class="uiTitle2 mt3">
                            <i class="uiTitle-icon"></i>
                            处理
                        </h2>
                        <ul class="handle-ul mt5">
                            <li :class="stage===0?'current':''" @click="cstageClick(0)">正常</li>
                            <li :class="stage===9?'current':''" @click="stageClick(9)">异常</li>
                            <li :class="stage===1?'current':''" @click="zstageClick(1)">整改</li>
                            <li :class="stage===2?'current':''" @click="dstageClick(2)">冻结</li>
                            <li :class="stage===4?'current':''" @click="pstageClick(4)">培训</li>
                            <li :class="stage===8?'current':''" @click="wstageClick(8)">问题</li>
                            <li :class="stage===6?'current':''" @click="clickFourShow(6,1)">离职</li>
                            <li :class="stage===11?'current':''" @click="cstageClick(11)">待离职</li>
                        </ul>
                        <ul class="handle-ul mt5" v-for="(item, index) in currentArray" :key='index'>
                            <li @click="liClick(index)" :class="item.flag && currentIndex === index ?'current':''">{{item.name}}</li>
                        </ul>
                    </div>
                    <div class="pr10">
                        <textarea class="evaluate-textarea" v-model="content"></textarea>
                    </div>
                </div>
                <div class="fl" style="width:38%">
                    <div class="tx-center pl5">
                        <div class="dis-il-block">
                            <div class="clearfix pb10 pt10">
                                <span class="fl lh28 ">积分：</span>
                                <strong class="pr5 fl lh28 cRed fz16">-</strong>
                                <div class="dis-il-block fl">
                                    <div class="inputw65 uiText-selfAuto">
                                        <input type="text" v-model="subIntegral" class="form-control noradius cRed">
                                        <div class="uiText-commonIcon uiText-commonIcon-right" style="line-height:auto">分</div>
                                    </div>
                                </div>
                                <strong class="pr5 fl lh28 cGreen fz16 ml4">+</strong>
                                <div class="dis-il-block fl">
                                    <div class="inputw65 uiText-selfAuto">
                                        <input type="text" v-model="addIntegral" class="form-control noradius">
                                        <div class="uiText-commonIcon uiText-commonIcon-right" style="line-height:auto">分</div>
                                    </div>
                                </div>
                            </div>
                            <div class="clearfix pb10">
                                <span class="fl lh28">奖罚：</span>
                                <strong class="pr5 fl lh28 cRed fz16">-</strong>
                                <div class="dis-il-block fl">
                                    <div class="inputw65 uiText-selfAuto">
                                        <input type="text" v-model="subMoney" class="form-control noradius cRed">
                                        <div class="uiText-commonIcon uiText-commonIcon-right" style="line-height:auto">元</div>
                                    </div>
                                </div>
                                <strong class="pr5 fl lh28 cGreen fz16 ml4">+</strong>
                                <div class="dis-il-block fl">
                                    <div class="inputw65 uiText-selfAuto">
                                        <input type="text" v-model="addMoney" class="form-control noradius">
                                        <div class="uiText-commonIcon uiText-commonIcon-right" style="line-height:auto">元</div>
                                    </div>
                                </div>
                            </div>
                            <!-- <div class="clearfix pb10">
                            <span class="fl lh28">方式：</span>
                            <strong class="pr5 fl lh28 cRed fz16">&nbsp; </strong>
                            <label class="uiRadio12 fl mt6"><input type="radio" name="a" class="uiRadio12-input">工资</label>
                            <label class="uiRadio12 fl mt6"><input type="radio" name="a" class="uiRadio12-input">立即支付</label>
                        </div> -->
                        </div>
                    </div>
                    <div class="tx-center pt10 pb10">
                        <input type="button" class="uiBtn-normal uiBtn-blue" @click="PersonHandler()" value="提交">
                    </div>
                </div>
            </div>
        </div>

        <!-- 四段渲染容器 -->
        <transition-group class="animated faster" enter-active-class="animated faster slideInRight" leave-active-class="animated faster slideOutRight">
            <!-- 问题 threeresultDetail -->
            <rx-administrationDetail v-if="fourIndex === 6" :key="0" :orderId="orderId"></rx-administrationDetail>
        </transition-group>
    </div>
</template>
<script>
import { updatePersonHandler, updatePmUserInfoLevelByUid } from '../Resources/Api/index'
import rxAdministrationDetail from './administration/administrationDetail4'
import { mapGetters } from 'vuex'
export default {
    data () {
        return {
            currentIndex: '-1', //  二段的Index
            stage: 0,
            yc: 0,
            currentArray: [],
            selectArray: [],
            addMoney: '',
            subMoney: '',
            addIntegral: '',
            subIntegral: '',
            content: '',
            isShow: true,
            fourIndex: undefined,
            roleId: 0 // 角色id
        }
    },
    components: {
        rxAdministrationDetail
    },
    created () {
        this.roleId = sessionStorage.getItem('roleId')
    },
    methods: {
        clickFourShow (index, flag) {
            this.fourIndex = index
            this.stage = index
        },
        liClick (currentIndex) {
            this.currentArray[currentIndex].flag = false
            this.currentIndex = currentIndex
            this.currentArray[currentIndex].flag = !this.currentArray[currentIndex].flag
            if (this.currentArray[currentIndex].flag) {
                this.selectArray.push(this.currentArray[currentIndex].name)
            } else {
                this.selectArray.splice(currentIndex, 1)
            }
            //  alert((this.selectArray)[currentIndex])
        },
        stageClick (stage) {
            this.selectArray = []
            this.stage = stage
            if (stage === 9) {
                this.currentArray = [{
                    flag: false,
                    name: '押金不够两万'
                }, {
                    flag: false,
                    name: '质保未收'
                }]
            }
        },
        zstageClick (stage) {
            this.selectArray = []
            this.stage = stage
            if (stage === 1) {
                this.currentArray = [{
                    flag: false,
                    name: '个人信息'
                }, {
                    flag: false,
                    name: '体检报告'
                }, {
                    flag: false,
                    name: '证件照'
                }, {
                    flag: false,
                    name: '银行卡'
                }, {
                    flag: false,
                    name: '艺术照'
                }, {
                    flag: false,
                    name: '身份证'
                }, {
                    flag: false,
                    name: '工人信息'
                }, {
                    flag: false,
                    name: '项目信息'
                }]
            }
        },
        dstageClick (stage) {
            this.selectArray = []
            this.stage = stage
            if (stage === 2) {
                this.currentArray = [{
                    id: 1,
                    flag: false,
                    name: '封停'
                }, {
                    id: 2,
                    flag: false,
                    name: '冻结'
                }, {
                    id: 3,
                    flag: false,
                    name: '纠纷'
                }]
            }
        },
        dlzageClick (stage) {
            this.selectArray = []
            this.stage = stage
        },
        pstageClick (stage) {
            this.selectArray = []
            this.stage = stage
            if (stage === 4) {
                this.currentArray = [{
                    flag: false,
                    name: '文修'
                }, {
                    flag: false,
                    name: '武练'
                }, {
                    flag: false,
                    name: '文修武练'
                }, {
                    flag: false,
                    name: '培训时间'
                }]
            }
        },
        wstageClick (stage) {
            this.selectArray = []
            this.stage = stage
            if (stage === 8) {
                this.currentArray = [{
                    flag: false,
                    name: '品德'
                }, {
                    flag: false,
                    name: '态度'
                }, {
                    flag: false,
                    name: '能力'
                }]
            }
        },
        cstageClick (stage) {
            this.selectArray = [1]
            this.stage = stage
            if (stage === 0) {
                this.currentArray = []
            }
            if (stage === 11) {
                this.currentArray = []
            }
        },
        PersonHandler () {
            if (this.stage !== 0 && this.selectArray.length === 0) {
                this.$message('请选择处理的二级标签！')
            }

            // stage=0和stage=7 代表 正常和待离职
            if (this.stage !== 6) {
                // let darry = []
                if (this.stage === 2) {
                    //     this.currentArray.forEach(element => {
                    //         if (element.flag === true) {
                    //             darry.push(element.id)
                    //         }
                    //     })
                }
                updatePmUserInfoLevelByUid({
                    state: this.selectArray[0],
                    orderno: this.leftInfo.uid,
                    createuserno: sessionStorage.getItem('userNo'),
                    createuserman: sessionStorage.getItem('userName'),
                    logcontent: this.content,
                    importance: this.stage,
                    logtype: 10
                }).then(res => {
                    if (res.data.StatusCode === 0) {
                        this.$message('处理成功！')
                        this.$router.go(0)
                        this.stage = 0
                        this.content = ''
                        this.addMoney = ''
                        this.subMoney = ''
                        this.addIntegral = ''
                        this.subIntegral = ''
                        this.currentArray = []
                        this.selectArray = []
                    }
                }).catch(err => {
                    console.log(err)
                })
            } else {
                updatePersonHandler({
                    uid: this.leftInfo.uid,
                    username: this.leftInfo.user_name,
                    userno: this.leftInfo.app_cardNo,
                    content: this.content,
                    secondTitle: this.selectArray,
                    addMoney: this.addMoney,
                    subMoney: this.subMoney,
                    addIntegral: this.addIntegral,
                    subIntegral: this.subIntegral,
                    taskState: 1
                }).then(result => {
                    if (result.data.StatusCode === 0) {
                        this.$message('处理成功！')
                        this.stage = 0
                        this.content = ''
                        this.addMoney = ''
                        this.subMoney = ''
                        this.addIntegral = ''
                        this.subIntegral = ''
                        this.currentArray = []
                        this.selectArray = []
                    }
                }).catch(error => {
                    console.log(error)
                    this.$$message('处理失败！')
                })
            }
        }
    },
    computed: {
        ...mapGetters(['leftInfo'])
    },
    watch: {
        leftInfo () {

        }
    }
}
</script>
